package com.netease.financial.internal.di.modules;

import android.content.Context;

import com.netease.financial.NfsApplication;
import com.netease.financial.UIThread;
import com.netease.financial.data.cache.NfsCache;
import com.netease.financial.data.cache.NfsCacheImpl;
import com.netease.financial.data.executor.JobExecutor;
import com.netease.financial.data.repository.NfsDataRepository;
import com.netease.financial.domain.executor.PostExecutionThread;
import com.netease.financial.domain.executor.ThreadExecutor;
import com.netease.financial.domain.repository.NfsRepository;
import com.netease.financial.navigation.Navigator;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Dagger module that provides objects which will live during the application lifecycle.
 */
@Module
public class ApplicationModule {
    private final NfsApplication application;

    public ApplicationModule(NfsApplication application) {
        this.application = application;
    }

    @Provides
    @Singleton
    Context provideApplicationContext() {
        return this.application;
    }

    @Provides
    @Singleton
    Navigator provideNavigator() {
        return new Navigator();
    }

    @Provides
    @Singleton
    ThreadExecutor provideThreadExecutor(JobExecutor jobExecutor) {
        return jobExecutor;
    }

    @Provides
    @Singleton
    PostExecutionThread providePostExecutionThread(UIThread uiThread) {
        return uiThread;
    }

    @Provides
    @Singleton
    NfsCache provideNfsCache(NfsCacheImpl nfsCache) {
        return nfsCache;
    }

    @Provides
    @Singleton
    NfsRepository provideNfsRepository(NfsDataRepository nfsDataRepository) {
        return nfsDataRepository;
    }
}
